package eight.test_8_3;

import java.util.Scanner;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        long max = 0;
        for (int i  = 0; i < n - 2; i++) {
            int count = Math.max(arr[i + 1],arr[i + 2]);
            max = Math.max(max,(long) arr[i] * count);
        }
        max = Math.max((long) arr[n - 2]*arr[n - 1],max);
        System.out.println(max);
    }
}
